package cool.taomu.toolkit.test

import com.google.inject.AbstractModule
import com.google.inject.Inject
import cool.taomu.toolkit.Taomu
import cool.taomu.toolkit.annotations.httpclient.HttpClient
import cool.taomu.toolkit.utils.ProxyUtils
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType

@HttpClient("http://hqm.stock.sohu.com")
@Path("/getqjson")
interface ITestService {
    
    @GET
    @Produces(MediaType.TEXT_HTML)
    def String getStock(@QueryParam("code") String code);
}


class ClientTest {
    
    @Inject
    ITestService test
    
    def static void main(String[] arg) {
        var injector = Taomu.getInjector().createChildInjector(new AbstractModule() {
            override configure() {
               
            }
        });
        var t = injector.getInstance(ClientTest).test
        ProxyUtils.isProxy(t)
        println(t.getStock("cn_601138"))
    }
}
